/**
 * Contains a role entity.
 */
package org.openfk.security.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotEmpty;

import com.sun.istack.NotNull;

/**
 * Role entity.
 * @author Sławomir Czerwiński
 * @version 1
 */
@Entity
@Table(name = "roles")
public class Role implements Serializable {
	/**
	 * Serial version.
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Role identifier.
	 */
	@Id @GeneratedValue @NotNull
	protected Integer id;

	/**
	 * Role name.
	 */
	@Length(max = 32,
			message = "")
	@NotEmpty
	protected String name;

	/**
	 * Role's application.
	 */
	@NotNull @ManyToOne
	@JoinColumn(
			name="id_application",
			referencedColumnName="id")
	protected Application application;

	/**
	 * Application identifier.
	 */
	@NotNull
	@Column(name = "id_application",
			insertable = false,
			updatable = false)
	protected Integer idApplication;

}
